<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>体育与健康课程管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/main.css"/>
    <link href="${pageContext.request.contextPath}/public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/public/js/layer/layer.js"></script>
</head>
<body>
<p style="margin-top:15px;margin-left:40px; font-size:16px; border-left:3px #006dcc solid; padding-left:5px">查看学生网络学习情况</p>
<div class="container clearfix" style="width:100%">
    <div class="main-wrap">
        <div class="search-wrap">
        	<div class="search-content">
        	<form action="${pageContext.request.contextPath}/studytime/searchstudytime.action" method="post">
        	 <table class="search-tab">
        	 	<th width="90" style="font-size:16px">学生姓名:</th>
        	 	<td><input type="text" class="common-text" style="height:32px" placeholder="学生姓名" name="userStudentInfoName" /></td>
        	 	 <td><button type="submit" class="btn btn-primary" onclick="">搜索</button></td>
        	 </form>
        	 
        	 
        	<form enctype="multipart/form-data" id="myform">
        	 	<th width="150px" style="font-size:16px">导入网络学习信息:</th>
        	 	<td><input type="file" name="file" /></td>
        	 	 <td><button type="button" id="noclick" value="不能重复导入数据" class="btn btn-primary" onclick="upload()">导入网络学习信息</button><span style="color:red"></span></td>
        	 	<td><button type="button" class="btn btn-success" onclick="window.location.href='${pageContext.request.contextPath}/public/moban/studytime.xlsx'">下载模板</button></td>
        	 </form>
        	 	</table>
        	</div>
        </div>
        <div class="result-wrap" >
               <div class="result-title">
                </div>
                <div class="result-content" id="app" >
                    <table class="result-tab" width="100%" id="addto">
                        <tr>
                            <th>学年</th>
                            <th>学生学号</th>
                            <th>姓名</th>
                            <th>班级</th>
                            <th>学院</th>
                            <th>年级</th>
                            <th>学习时长（分钟）</th>
                        </tr>
                      <c:forEach items="${data}" var="v">
                        <tr >
                            <td>${nowyear}</td>
                         	<td>${v.userStudentInfoNum }</td>
                         	<td>${v.userStudentInfoName }</td>
                         	<td>${v.userStudentInfoClass }</td>
                         	<td>${v.userStudentInfoSchool }</td>
                         	<td>${v.userStudentInfoYear }</td>
                         	<td>${v.studytime }</td>
                            </tr>
  					</c:forEach>
                    </table>
                </div>
                </div>
               <div class="row">
				<div class="col-md-3">当前${page.pageNow }页,总${page.totalPageCount }
				页,总${page.totalCount}条记录</div>
                <div class="col-md-9">
				<nav aria-label="Page navigation">
				<ul class="pagination">
					<li><a href="${pageContext.request.contextPath}/studytime/studytime.action?pn=1">首页</a></li>
					<c:if test="${page.hasPre}">
						<li><a href="${pageContext.request.contextPath}/studytime/studytime.action?pn=${page.pageNow-1}"
							aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
						</a></li>
					</c:if>

					<li class="active"><a href="#">${page.pageNow}</a></li> 
					<c:if test="${page.pageNow<page.totalPageCount }">
						<li><a href="${pageContext.request.contextPath}/studytime/studytime.action?pn=${page.pageNow+1 }"
							aria-label="Next"> <span aria-hidden="true">&raquo;</span>
						</a></li>
					</c:if>
					<li><a href="${pageContext.request.contextPath}/studytime/studytime.action?pn=${page.totalPageCount}">末页</a></li>
				</ul>
				</nav>
			</div>
			</div>

    </div>
</div>

</body>
<script type="text/javascript">

function upload()
{
	$("#noclick").attr('disabled',true);
	layer.load(0,{ offset: ['15px', '40%'], icon:5});
	 var formData = new FormData($("#myform")[0]);//获取表单数据        
     $.ajax({
          url: "${pageContext.request.contextPath}/studytime/upload.action",//提交地址
          type: 'POST',
          data: formData,
          async: true,
          cache: false,
          contentType: false,
          processData: false,
          success: function (returndata) {
           if(returndata.code==1){
        	   layer.closeAll('loading');
               layer.msg(returndata.message, { offset: ['0px', '40%'], icon:6,time:2000},function(){
                   location.reload(); 
                 });
               $("#noclick").removeAttr('disabled'); 
           }
           else{
        	   layer.closeAll('loading');
        	   $("#noclick").removeAttr('disabled'); 
           		layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:2000});  
           }
          },
          error: function (returndata) {
           layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:2000});

      }
     });   
	
	}
</script>
</html>